<template>
	<div>
		<div class="count" v-on:click="toOddDetail">
			<span class="title">最近24小时订单统计</span>

			<div class="context">
				<div>已完成数量：{{success_num}}单</div>
				<div>未完成数量：{{waite_num}}单</div>
			</div>
			<div class="subject">往来单位：{{out_subject_str}}</div>
		</div>


	</div>
</template>

<script>
	import {
		get_all_odd
	} from '../../utils/get_all_odd.js'
	export default {
		name: '',
		components: {},
		props: {},
		data() {
			return {
				success_num: 0,
				waite_num: 0,

				out_subject_str: '',

				all_odd_list: [],

			}
		},
		methods: {
			toOddDetail() {
				this.$router.push({
					name: 'Inventory'
				})
			},


		},
		computed: {},
		watch: {},
		created() {},
		mounted() {

			// console.log('xxx')

			get_all_odd(
				res => {
					this.all_odd_list = res

					// console.log(res)
					let subject_list = []
					for (let item of res) {

						if (item.end_time != null && item.end_time > (Date.now().valueOf() / 1000 - 24 * 3600)) {
							this.success_num++
						}

						if (item.status == 'wait') {
							this.waite_num++
						}

						if (item.in_or_out == false) {

							subject_list.push(item.subject_name)
						}


					}
					

					this.out_subject_str =  [... new Set(subject_list)].join('|')
				}
			)

		},
	}
</script>

<style scoped lang="less">
	.count {
		width: 100%;
		margin-top: 5px;
		background-color: #F0F0F0;

		.title {
			display: block;
			font-weight: 800;
			margin-left: 5px;
		}

		.context {
			display: flex;
			justify-content: space-between;
			margin: 10px;
		}

		.subject {
			margin: 10px;
		}
	}
</style>
